function oldmagician(filename)

% base case  1: [1 1] = [0 1]
% base case  2: [2 0] = [1 0]
% base case  3: [0 2] = [1 0]
% transition 1: [w b] = [w+1 b-2]  % two blacks
% transition 2: [w b] = [w-1 b  ]  % two whites, or one black and one white
% an odd number of black balls always result in the last ball being black
% an even number of black balls always result in the last ball being white

fin = fopen(filename);
ntests = fscanf(fin, '%d', 1);
X = fscanf(fin, '%d %d\n', ntests*2);
X = reshape(X, [2, ntests])';
fclose(fin);

fout = fopen([filename '.res'], 'wt');
for i = 1:size(X, 1)
    if rem(X(i,2), 2)==0
        fprintf(fout, 'Case #%d: WHITE\n', i);
    else
        fprintf(fout, 'Case #%d: BLACK\n', i);
    end
end
fclose(fout);
